package com.sww.pj.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sww.pj.common.exception.ServiceException;
import com.sww.pj.common.pojo.PageObject;
import com.sww.pj.sys.dao.WzFfdao;
import com.sww.pj.sys.pojo.Syswuzi;
import com.sww.pj.sys.service.WuziService;

@Service
public class SyswuziServiceimpl implements WuziService {
    @Autowired
	private WzFfdao wzFfdao; 
	
	  
	@Override
	public PageObject<Syswuzi> findPageObjects(String wzname, Long pageCurrent) {
		//1.参数有效性校验
				if(pageCurrent==null||pageCurrent<1)
					throw new IllegalArgumentException("页码值无效");
				//2.查询总记录数并校验
				long rowCount=wzFfdao.getRowCount(wzname);
				if(rowCount==0)
					throw new ServiceException("没有找到对应记录");
				//3.查询当前页记录
				int pageSize=6;
				long startIndex=(pageCurrent-1)*pageSize;
				List<Syswuzi> records=
			wzFfdao.findPageObjects(wzname, startIndex, pageSize);
				//4.封装查询结果并返回
				return new PageObject<>(rowCount, records, pageSize, pageCurrent);

	}

}
